const { defineConfig } = require("@vue/cli-service");
const AutoImport = require("unplugin-auto-import/webpack");
const Components = require("unplugin-vue-components/webpack");
const { ElementPlusResolver } = require("unplugin-vue-components/resolvers");
const path = require("path");

module.exports = defineConfig({
    transpileDependencies: true,
    configureWebpack: {
        resolve: {
            alias: {
                // 确保有 @ -> src 的映射
                "@": path.resolve(__dirname, "src"),

                // 添加扩展名解析（重要！）
                extensions: [".js", ".ts", ".vue", ".json"]
            }
        },
        //配置webpack自动按需引入element-plus，
        plugins: [
            AutoImport({
                imports: ["vue", "vue-router"],
                resolvers: [ElementPlusResolver()]
            }),
            Components({
                resolvers: [ElementPlusResolver()]
            })
        ]
    }
});
